function wailianStaticMethod(url,key,params,pushstatus,backstatus) {
    var userAgent = navigator.userAgent.toLowerCase();
    var system = getSystem(userAgent);
    var browser = getBrowser(userAgent);
    var device = getDevice(userAgent);
    var code = inviteCode();
    var deviceInfo = {"system": system, "browser": browser, "device": device, "code": code};
    var requestparams = Object.assign(params, deviceInfo);
    if (backstatus) {
        wailianStaticBack(requestparams);
    }
    if (pushstatus) {
        pushApiInfo(requestparams,url,key);
    }
}

function getSystem(userAgent) {
    if (userAgent.search("windows nt") != -1) {
        pvendor = 4;
    } else if (userAgent.search("iphone") != -1) {
        pvendor = 2;
    } else if (userAgent.search("ipad") != -1) {
        pvendor = 3;
    } else if (userAgent.search("android") != -1) {
        pvendor = 1;
    } else if (userAgent.search("macintosh") != -1) {
        pvendor = 5;
    } else {
        pvendor = 0;
    }
    return pvendor;
}

function getBrowser(userAgent) {
    // 判断访问是什么设备
    if (userAgent.search('micromessenger') != -1) {
        // 微信浏览器
        browser = "1";
    } else if(userAgent.search('qqbrowser') != -1){
        // 电脑QQ浏览器
        browser = "2";
    } else if(userAgent.search('vivobrowser') != -1){
        // Vivo浏览器
        browser = "3";
    } else if(userAgent.search('heytapbrowser') != -1){
        // Oppo浏览器
        browser = "4";
    } else if(userAgent.search('huaweibrowser') != -1){
        // 华为浏览器
        browser = "5";
    } else if(userAgent.search('miuibrowser') != -1){
        // 小米浏览器
        browser = "6";
    } else if(userAgent.search('mqqbrowser') != -1){
        // QQ浏览器
        browser = "7";
    } else if(userAgent.search('alipayclient') != -1){
        // 支付宝浏览器
        browser = "8";
    } else if(userAgent.search('baiduboxapp') != -1){
        // 百度APP
        browser = "9";
    } else if(userAgent.search('weibo') != -1){
        // 微博浏览器
        browser = "10";
    } else if(userAgent.search('iqiyi') != -1){
        // 爱奇艺浏览器
        browser = "11";
    } else if(userAgent.search('miuibrowser') != -1 || userAgent.search('xiaomi') != -1){
        // 小米浏览器
        browser = "12";
    } else if(userAgent.search('bytelocale') != -1 || userAgent.search('bytedancewebview') != -1){
        // 抖音浏览器
        browser = "26";
    } else if(userAgent.search('kdtunion_iting') != -1){
        // 喜马拉雅
        browser = "13";
    } else if(userAgent.search('dingtalk') != -1){
        // 钉钉
        browser = "14";
    } else if(userAgent.search('ucbrowser') != -1){
        // UC浏览器
        browser = "15";
    } else if(userAgent.search('samsungbrowser') != -1){
        // 三星浏览器
        browser = "16";
    } else if(userAgent.search('nokiabrowser') != -1){
        // 诺基亚浏览器
        browser = "17";
    } else if(userAgent.search('opera') != -1){
        // 欧朋
        browser = "18";
    } else if(userAgent.search('firefox') != -1){
        // 火狐
        browser = "19";
    } else if(userAgent.search('zhihu') != -1 || userAgent.search('hihu') != -1){
        // 知乎
        browser = "20";
    } else if(userAgent.search('larkLocale') != -1){
        browser = "21";
    } else if(userAgent.search('iphone') != -1){
        browser = "22";
    } else if(userAgent.search('ipad') != -1){
        browser = "23";
    } else if(userAgent.search('macintosh') != -1){
        browser = "24";
    } else {
        browser = "25";
    }
    return browser;
}

function getDevice(userAgent) {
    var isIphone = userAgent.match(/iphone/i) == "iphone";
    var isHuawei = userAgent.match(/huawei/i) == "huawei";
    var isHonor = userAgent.match(/honor/i) == "honor";
    var isOppo = userAgent.match(/oppo/i) == "oppo";
    var isRealme = userAgent.match(/rmx/i) == "rmx";
    var isOppoR15 = userAgent.match(/pacm00/i) == "pacm00";
    var isVivo = userAgent.match(/vivo/i) == "vivo";
    var isXiaomi = userAgent.match(/mi\s/i) == "mi ";
    var isXiaomi2s = userAgent.match(/mix\s/i) == "mix ";
    var isRedmi = userAgent.match(/redmi/i) == "redmi";
    var isSamsung = userAgent.match(/sm-/i) == "sm-";
    if (isIphone) {
        return 6;
    } else if (isHuawei || isHonor) {
        return 1;
    } else if (isOppo || isOppoR15 || isRealme) {
        return 4;
    } else if (isVivo) {
        return 2;
    } else if (isXiaomi || isRedmi || isXiaomi2s) {
        return 3;
    } else if (isSamsung) {
        return 5;
    } else {
        return 0;
    }
}

function inviteCode() {
    var name = "channel";
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    var code = "";
    if (r != null) code = unescape(r[2]);
    if (code.length > 10) return "";
    return code;
}

function pushApiInfo(requestparams,url,key) {
    var urlscheme_time = Math.round(new Date().getTime()/1000).toString();
    var usersview = localStorage.getItem("ttwlstatic_"+key) || "";
    var review = 1;
    if (usersview == ""){
        // 未访问,执行推送
        localStorage.setItem("ttwlstatic_"+key,key);
    } else {
        return;
    }
    requestparams["links_id"] = key;
    requestparams["sorts"] = 1;
    $.ajax({
        "type":"POST",
        "url": url,
        "data":requestparams,
        success:(res)=>{}
    });
    return "success";
}
